package Demo9;

import java.util.concurrent.ArrayBlockingQueue;

public class Consumer extends Thread{
    private ArrayBlockingQueue<String> queue;

    public Consumer(ArrayBlockingQueue<String> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while ( true ) {
            String str = null;
            try {
                str = queue.take();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println(getName()+"消费了一件物品"+str);
        }
    }
}
